${title}
package ${serviceImplPackage};
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.repository.Model;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jysoft.map.common.util.StringUtil;
import com.jysoft.map.onestop.common.FlowConstant;
import com.jysoft.map.onestop.common.entity.R;
import com.jysoft.map.onestop.common.exception.DataUpdatedException;
import com.jysoft.map.onestop.common.service.BaseSerivce;
import com.jysoft.map.onestop.common.util.EmptyUtil;
import com.jysoft.map.onestop.common.util.JxlsUtil;
import com.jysoft.map.onestop.common.util.UUIDUtil;

import ${entityPackage}.${className};

//import com.jysoft.map.onestop.plan.entity.${className}Detail;
//import com.jysoft.map.onestop.plan.entity.${className}Export;
//import com.jysoft.map.onestop.plan.mapper.${className}DetailMapper;

import ${mapperInterfacePackage}.${className}Mapper;
import ${servicePackage}.${className}Service;
import com.sgcc.uap.utils.datetime.DateUtil;


 /**
 * <ul>
 * <li>Title: ${proName}-${className}ServiceImpl</li>
 * <li>Description:${tablecomment}ServiceImpl </li>
 * <li>Copyright: Copyright (c) 2018</li>
 * <li>Company: http://www.spic.com.cn/</li>
 * </ul>
 *
 * @author ${author}
 * @version ${version}
 * @date ${date?datetime}
 */
@Service
public class ${className}ServiceImpl extends BaseOaService implements ${className}Service {

	@Autowired
	private ${className}Mapper ${classObjectName}Mapper;

	/**
    	 * 分页查询
    	 *
    	 * @param page
    	 *            分页条件
    	 * @param ${classObjectName}
    	 *            查询条件
    	 * @return IPage<${className}> 查询结果
    	 */
    	@Transactional(readOnly = true)
    	public IPage<${className}> listPage(Page<${className}> page, ${className} ${classObjectName}) {
    		return ${classObjectName}Mapper.listPage(page, ${classObjectName});
    	}

    	/**
    	 * 更新页面初期化
    	 *
    	 * @param id
    	 *            主键
    	 * @return 更新页面数据
    	 */
    	@Transactional(readOnly = true)
    	public ${className} updateInit(String id) {
    		${className} ${classObjectName} = ${classObjectName}Mapper.selectByPrimaryKey(id);
    		//if (!EmptyUtil.isNullOrEmpty(${classObjectName}.getId())) {
    			//${classObjectName}.setListFlowHistory(flowTimeLine(${classObjectName}.getProcDefId(),${classObjectName}.getProcInstId()));
    		//}
    		return ${classObjectName};
    	}

    	/**
    	 * 保存操作
    	 *
    	 * @param ${classObjectName}
    	 *            保存内容
    	 * @return 保存结果
    	 */
    	@Transactional(readOnly = false)
    	public R save(${className} ${classObjectName}) {
    		${classObjectName}.setId(UUIDUtil.guid());
    		//${classObjectName}.setStatus("DFQ");
    		${classObjectName}Mapper.commonInsert(${classObjectName});
    		//if (${classObjectName}.getDetailList() != null && ${classObjectName}.getDetailList().size() > 0) {
    		//	for (${className}Detail ${classObjectName}Detail : ${classObjectName}.getDetailList()) {
    		//		${classObjectName}Detail.setId(UUIDUtil.guid());
    		//		${classObjectName}Detail.setCreateUser(${classObjectName}.getCreateUser());
    		//		${classObjectName}Detail.setUpdateUser(${classObjectName}.getUpdateUser());
    		//		${classObjectName}Detail.setCatalogId(${classObjectName}.getId());
    		//	}
    		//	${classObjectName}DetailMapper.insertBatch(${classObjectName}.getDetailList());
    		//}
    		return new R(Boolean.TRUE, "保存成功！");
    	}

    	/**
    	 * 更新操作
    	 *
    	 * @param ${classObjectName}
    	 *            更新内容
    	 * @return 更新结果
    	 */
    	@Transactional(readOnly = false)
    	public R update(${className} ${classObjectName}) {
    		// 业务代码唯一性判断
    		int updateCount = ${classObjectName}Mapper.commonUpdate(${classObjectName});
    		if (updateCount == 0) {
    			throw new DataUpdatedException("数据已被其他人更新，请重新查询数据。");
    		}
    		// 插入详情
    		//${classObjectName}DetailMapper.delete(Wrappers.<${className}Detail>query().lambda()
    		//		.eq(${className}Detail::getCatalogId, ${classObjectName}.getId()));

    		//if (${classObjectName}.getDetailList() != null && ${classObjectName}.getDetailList().size() > 0) {
    		//	for (${className}Detail detail : ${classObjectName}.getDetailList()) {
    		//		detail.setId(UUIDUtil.guid());
    		//		detail.setCreateUser(${classObjectName}.getCreateUser());
    		//		detail.setUpdateUser(${classObjectName}.getUpdateUser());
    		//		detail.setCatalogId(${classObjectName}.getId());
    		//	}
    		//	${classObjectName}DetailMapper.insertBatch(${classObjectName}.getDetailList());
    		//}
    		return new R(Boolean.TRUE, "更新成功！");
    	}

/**
	 * 删除操作
	 *
	 * @param ids
	 *            删除主键
	 * @param updateTimes
	 *            更新时间（排他用)
	 * @return 删除结果
	 */
	@Transactional(readOnly = false)
	public R delete(String[] ids) {
		${className} ${classObjectName} = null;
		for (int i = 0; i < ids.length; i++) {
			${classObjectName} = new ${className}();
			${classObjectName}.setId(ids[i]);
			//${classObjectName}.setUpdateTimeStr(updateTimes[i]);
			int count = ${classObjectName}Mapper.commonDelete(${classObjectName});
			if (count == 0) {
				throw new DataUpdatedException("数据已被其他人更新，请重新查询数据。");
			}
		}
		return new R(Boolean.TRUE, "删除成功！");
	}

}